package com.yanqu.road.server.cmd.activity.peakstronghold.cross;

import com.yanqu.road.entity.activity.peakstronghold.config.PeakStrongHoldConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PeakStrongholdWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.peakstronghold.PeakStrongholdActivityMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = GameProtocol.S_PEAK_STRONGHOLD_NOTIFY_WAIT_PREPARE_UPDATE_END_CONFIRM, desc = "通知确认准备阶段的数据都传完了")
public class CrossPeakStrongholdNotifyConfirmUpdateDefendEndCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        PeakStrongholdWarProto.CrossPeakHoldCommonMsg reqMsg = PeakStrongholdWarProto.CrossPeakHoldCommonMsg.parseFrom(packet.getBytes());
        PeakStrongholdActivityMgr.confirmUpdateDefendPatronsEnd(reqMsg.getUnionGroup());
        PeakStrongHoldConfig config = PeakStrongholdActivityMgr.getConfig();
        if (config != null) {
            PeakStrongholdWarProto.CrossPeakHoldConfirmReceiveMsg.Builder crossMsg = PeakStrongholdWarProto.CrossPeakHoldConfirmReceiveMsg.newBuilder();
            crossMsg.setActivityId(config.getActivityInfo().getActivityId());
            crossMsg.setProtocolCode(GameProtocol.S_PEAK_STRONGHOLD_NOTIFY_WAIT_PREPARE_UPDATE_END_CONFIRM);
            GamePlayerMgr.sendUnionActivityGroupPacket(CrossProtocol.C_PEAK_STRONGHOLD_GAMESERVER_CONFIRM_RECEIVE, crossMsg, 0 , config.getActivityInfo().getActivityId(), reqMsg.getUnionGroup());
        }
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
